$(function () {
    let markId = getUrlString('markid');
    let type = getUrlString('type');
    let page = -1,time = '3',mainseries = '',maker = '',totalSize;

    let mRefresh = new MiniRefresh({
        container: '#mrefresh', //这里是插件的容器ID
        down: {
            isAuto: false,
            callback: function () {
                // 下拉后的回调事件 ，你可以在这里执行你的后台请求数据函数，达到刷新数据的作用
                $('#usedList').empty();
                totalSize = 0;
                page = -1;
                mRefresh.endDownLoading();
            }
        }
        ,
        up: {
            isAuto: true,
            callback: function () {
                // 向上拉后的回调事件
                page += 1;
                getListData(page,time,mainseries,maker);
            }
        }
    });

    function getListData (page,time,mainseries,maker){
        let data = {
            'page':page,
            'markid':markId,
            'type':type,
            'time':time,
            'mainseries':mainseries,
            'maker':maker,
        };
        getData('post','/niu/apiv4/niu_cate_allsearch.php',data,function (data) {
            console.log(data);
            let append = '';
            $(data.info).each(function () {
                append += '<li>' +
                    ' <input type="hidden" value="'+this.id+'"> '+
                    '                <img src="'+this.logo+'" alt="">' +
                    '                <p>'+this.name+'</p>' +
                    '            </li>'
            });
            $('#usedList').append(append);


            totalSize = totalSize + 50;
            if (totalSize > data.datacount){
                mRefresh.endUpLoading(true);
            } else{
                mRefresh.resetUpLoading(true);
                mRefresh.endUpLoading(false);
            }
        })
    }
    $("#usedList li").live("click", function(){
        let id = $(this).find('input').val();
        window.location.href = 'dancool://web='+urlView+'productData/dataDetail.html?id='+id+'&cateType='+type;
    });

});